// @ts-nocheck

export namespace ViriableDemo{

  export namespace AnyDemo{
    let x:any;
    x = 1; // 正确
    x = 'foo'; // 正确
    x = true; // 正确

    function  anyDemo(){
      console.debug(x)
    }
  }

}


export namespace ClassDecorator {
  export
  // 加上通过类型提示
  interface Person {
    name: string
    // address: string
  }

  /**
   * 调用在构造函数之前
   * @param target 充分必要参数，为其所装饰的类本身
   * @param context 上下文对象
   */
  function enhancer(target: any, context: any) {
    // 给被装饰类新增打印方法
    target.prototype.printFunction = function(value:string){
      console.log("装饰器新增打印方法：" + value)
    }

    console.log('class enhancer')
    console.log('target:' + target)
    console.log('context:' + context.kind)
    target.prototype.name = 'TS 装饰器'
    target.prototype.value = "装饰器添加的值"
    // target.prototype.address = 'ECMAScript 2022'
  }

  @enhancer // 普通装饰器
  export class Person {
    // printFunction(arg0: string) {
    //   // throw new Error("Method not implemented.")
    // }
    constructor() {
      console.log("Person 构造器被调用")
    }
  }

  @enhancer
  export class ClassDemo{
    name:string

    constructor(){
      this.name = ""
      console.log("ClassDemo 构造器被调用")
    }

  }

}

const person = new ClassDecorator.Person()
console.log(person.name)
person.printFunction("person")
// console.log(person.value)
// console.log(person.address)

const classDemo = new ClassDecorator.ClassDemo()
console.log(classDemo.name)


class A{
  data1: string|number = ""

}

class B extends A{
  data2: string = ""
}

interface B{
  data3: string
}

class C extends B{
  constructor(v1:string, v2:string){
    this.data2 = v1
    this.data3 = v2
  }
}
